package com.mysterymall.Controller.Admin;

import com.mysterymall.Common.Comp.Log;
import com.mysterymall.Common.Utils.Result;
import com.mysterymall.Model.Dto.LoginDto;
import com.mysterymall.Model.Dto.UserDto;
import com.mysterymall.Service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @ClassName com.mysterymall.Controller.Admin
 * @Description
 * @Author HuangWX
 * @Time 2023/11/05  15:28
 */
@RestController
@RequestMapping("/user")
public class AdminUserCont {


    @Autowired
    private UserService userService;

    /**
     * 获取所有用户
     * @return Result
     */
    @GetMapping("/getAllUser")
    @Log
    public Result getAllUser(@RequestParam(value = "currIndex", defaultValue = "0") Integer page,
                             @RequestParam(value = "pageSize", defaultValue = "0") Integer size){
        return userService.getAllUser(page,size);
    }

    /**
     * 模糊搜索获取用户信息
     * @return Result
     */
    @GetMapping("/userInfoFuzzySearch")
    @Log
    public Result userInfoFuzzySearch(@RequestParam(value = "search") String search){
        return userService.userInfoFuzzySearch(search);
    }

    /**
     * 修改用户信息
     * @param userDto 用户信息
     * @return Result
     */
    @PostMapping("/updateUserInfo")
    @Log
    public Result updateUserInfo(@RequestBody UserDto userDto){
        return userService.updateUserInfo(userDto);
    }

}
